import { Component, OnInit, Input } from '@angular/core';
import { Router } from '@angular/router';
import { CommondataService } from '../../service/commondata/commondata.service';

@Component({
  selector: 'app-message',
  templateUrl: './message.component.html',
  styleUrls: ['./message.component.less']
})
export class MessageComponent implements OnInit {

  @Input() Lists: Array<any> = [];
  @Input() isAllData: any = true;
  @Input() isTheBest: any = false;
  @Input() arriveFlag: any;
  User: any = {};
  lists: Array<any> = [];

  isVisible: boolean = false;     // 提示用户登录的提示框的显隐标志

  constructor(private router: Router, private commonData: CommondataService) { }

  ngOnInit() {

    this.User = this.commonData.user;
  }

  // 用户如果没有注册想要查看数据用户的联系方式，需要提醒用户必须登录才能查看，则打开提示框
  pleaseLogin() {
    this.isVisible = true;
  }
  // 用户点击取消后关闭提示框
  handleCancel() {
    this.isVisible = false;
  }
  // 用户点击登录后进入用户登录界面
  handleLogin() {
    this.isVisible = false;
    this.router.navigateByUrl('/login');
  }
  // 用户点击注册后进入注册界面
  handleRegister() {
    this.isVisible = false;
    this.router.navigateByUrl('/register');
  }

}
